/*
 * Copyright (c) 2024 Fujian Newland Auto-ID Tech.Co.,Ltd.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
import data_rdb from '@ohos.data.relationalStore'

export const BOOK_TABLE_NAME = 'book'

export const SQL_CREATE_BOOK_TABLE = 'CREATE TABLE IF NOT EXISTS book(id TEXT PRIMARY KEY, ' +
  'title TEXT NOT NULL, ' +
  'pinyin_alias TEXT NOT NULL, ' +
  'author TEXT, ' +
  'publisher TEXT NOT NULL, ' +
  'publisher_data INTEGER, ' +
  'price INTEGER, ' +
  'category INTEGER, ' +
  'describe TEXT NOT NULL, ' +
  'stock INTEGER, ' +
  'status INTEGER, ' +
  'img TEXT, ' +
  'score INTEGER, ' +
  'borrow_count INTEGER, ' +
  'recommendation TEXT, ' +
  'layer_id TEXT, ' +
  'shelves_id TEXT, ' +
  'bg_img TEXT, ' +
  'want_see INTEGER, ' +
  'upvote INTEGER, ' +
  'reads TEXT)'

export const BOOK_COLUMNS =
  ['id', 'title', 'pinyin_alias', 'author', 'publisher', 'publisher_data', 'price', 'category',
    'describe', 'stock', 'status', 'img', 'score', 'borrow_count', 'recommendation', 'layer_id', 'shelves_id', 'bg_img',
    'want_see', 'upvote', 'reads']


export const BOOK_SHELVING_TABLE_NAME = 'book_shelving'

export const SQL_CREATE_BOOK_SHELVING_TABLE =
  'CREATE TABLE IF NOT EXISTS book_shelving(id TEXT PRIMARY KEY, book_id TEXT, layer_id TEXT)'

export const BOOK_SHELVING_COLUMNS = ['id', 'book_id', 'layer_id']


export const BORROW_RECORD_NAME = 'borrow_record'

export const SQL_CREATE_BORROW_RECORD_TABLE = 'CREATE TABLE IF NOT EXISTS borrow_record(id TEXT PRIMARY KEY, ' +
  'user_id TEXT, ' +
  'book_id TEXT, ' +
  'borrow_date INTEGER, ' +
  'return_date INTEGER)'

export const BORROW_RECORD_COLUMNS = ['id', 'user_id', 'book_id', 'borrow_date', 'return_date']

export const SHELF_LAYER_NAME = 'shelf_layer'

export const SQL_CREATE_SHELF_LAYER_TABLE = 'CREATE TABLE IF NOT EXISTS shelf_layer(id TEXT PRIMARY KEY, ' +
  'shelf_id TEXT, ' +
  'level INTEGER, ' +
  'name TEXT)'

export const SHELF_LAYER_COLUMNS = ['id', 'shelf_id', 'level', 'name']

export const SHELVES_NAME = 'shelves'

export const SQL_CREATE_SHELVES_TABLE = 'CREATE TABLE IF NOT EXISTS shelves(id TEXT PRIMARY KEY, ' +
  'name TEXT, ' +
  'location TEXT)'

export const SHELVES_COLUMNS = ['id', 'name', 'location']

export const USER_NAME = 'user'

export const SQL_USER_TABLE = 'CREATE TABLE IF NOT EXISTS user(id TEXT PRIMARY KEY, ' +
  'name TEXT, ' +
  'pwd TEXT, ' +
  'phone TEXT, ' +
  'role INTEGER, ' +
  'icon TEXT)'

export const USER_COLUMNS = ['id', 'name', 'pwd', 'phone', 'role', 'icon']

export interface BookStoreConfig {
  name: string;
  securityLevel: number;
}

export const BOOK_STORE_CONFIG: BookStoreConfig = { name: 'nl_e_lib_rfid.db', securityLevel: data_rdb.SecurityLevel.S1 }